class ReposCollaborators
  attr_accessor :github

  def initialize(github)
    @github = github
  end

  def list(repo, user=nil)
    username = user == nil ? @github.username : user
    @github.get('repos/%s/%s/collaborators' % [username, repo])
  end

  def get(repo, collaborator, user=nil)
    username = user == nil ? @github.username : user
    @github.get('repos/%s/%s/collaborators/%s' % [username, repo, collaborator])
  end

  def addCollaborator(repo, collaborator, user=nil)
    username = user == nil ? @github.username : user
    @github.put('repos/%s/%s/collaborators/%s' % [username, repo, collaborator])
  end

  def deleteCollaborator(repo, collaborator, user=nil)
    username = user == nil ? @github.username : user
    @github.delete('repos/%s/%s/collaborators/%s' % [username, repo, collaborator])
  end
end